using AutoMapper;
using Common.Views;
using Dto.ApiResponses;
using Dto.ApiResponses.AccountResponses;
using Dto.ApiResponses.AttachmentResponses;
using Dto.ApiResponses.ConfigResponses;
using Dto.ApiResponses.ContactResponses;
using Dto.ApiResponses.FolderResponses;
using Dto.ApiResponses.HealthResponses;
using Dto.ApiResponses.LeadResponses;
using Dto.ApiResponses.MemberResponses;
using Dto.ApiResponses.NoteResponses;
using Dto.ApiResponses.TaskLogResponses;
using Dto.ApiResponses.TemplateResponses;
using Dto.ApiResponses.TrackLogResponses;
using PetaPoco;
using Sanelib.Common.SystemSettings;
using Sanelib.Core.Entity;

namespace WebApp.Initialization.Automapper
{
    public class ViewToResponseProfile : Profile
    {
        protected override void Configure()
        {
            // member
            CreateMap<MemberView, MemberResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            CreateMap<MemberView, MemberLine>()
                .ForMember(x => x.RoleName, o => o.Ignore())
                .ForMember(x => x.UserStatusName, o => o.Ignore());
            CreateMap<Page<MemberView>, PageResponse<MemberLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // health
            CreateMap<HealthView, HealthResponse.HealthLine>();

            CreateMap<EmailConfig, EmailConfigResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // configuration
            CreateMap<SmsConfig, SmsConfigResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            CreateMap<NetworkConfig, NetworkConfigResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // templete
            CreateMap<TempleteView, TemplateLine>();
            CreateMap<TempleteView, TemplateResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<TempleteView>, PageResponse<TemplateLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // lead
            CreateMap<LeadView, LeadLine>();
            CreateMap<LeadView, LeadResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<LeadView>, PageResponse<LeadLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // contact
            CreateMap<ContactView, ContactLine>();
            CreateMap<ContactView, ContactResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<ContactView>, PageResponse<ContactLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // assignedContact
            CreateMap<AssignedContactView, AssignedContactLine>();
            CreateMap<AssignedContactView, AssignedContactResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<AssignedContactView>, PageResponse<AssignedContactLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // account
            CreateMap<AccountView, AccountLine>();
            CreateMap<AccountView, AccountResponse>()
              .ForMember(x => x.RedirectRequired, o => o.Ignore())
              .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<AccountView>, PageResponse<AccountLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // folder
            CreateMap<FolderView, FolderLine>();
            CreateMap<FolderView, FolderResponse>()
             .ForMember(x => x.RedirectRequired, o => o.Ignore())
             .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<FolderView>, PageResponse<FolderLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            // memberview to guid-name pair
            CreateMap<MemberView, GuidNamePair>();

            // note
            CreateMap<NoteView, NoteLine>();

            // attachment
            CreateMap<AttachmentView, AttachmentLine>();

            // taskLog
            CreateMap<TaskLogView, TaskLogLine>();
            CreateMap<TaskLogView, TaskLogResponse>()
               .ForMember(x => x.RedirectRequired, o => o.Ignore())
               .ForMember(x => x.Uri, o => o.Ignore());
            CreateMap<Page<TaskLogView>, PageResponse<TaskLogLine>>()
               .ForMember(x => x.RedirectRequired, o => o.Ignore())
               .ForMember(x => x.Uri, o => o.Ignore());

            //trackLog
            CreateMap<TrackLogView, TrackLogLine>();
            CreateMap<TrackLogView, TrackLogResponse>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

            CreateMap<Page<TrackLogView>, PageResponse<TrackLogLine>>()
                .ForMember(x => x.RedirectRequired, o => o.Ignore())
                .ForMember(x => x.Uri, o => o.Ignore());

        }
    }
}